<?php 

require_once("../shared/connect.php");

$read = mysql_query("SELECT DISTINCT full_address AS value, MAX(core) AS core
					 FROM geocode
					 WHERE (input_address LIKE '%$_GET[term]%' OR full_address LIKE '%$_GET[term]%')
					 GROUP BY full_address
					 ORDER BY core DESC, access_frequency DESC
					 LIMIT 15
					 ") 
		or die(mysql_error());

$list = array();

while ($row = mysql_fetch_assoc($read)) {
	$list[] = $row;
}

echo json_encode($list);

?>